package org.cainiao.jvm.loadclass;

/**
 * <br />
 * <p>
 * Author: Cai Niao(wdhlzd@163.com)<br />
 */
public class LoadClassTest {

    public static void main(String[] args) {
        String test1 = "org.cainiao.jvm.loadclass.Test1";
        System.out.println("Classloader");
        // testClassloader(test1);
        System.out.println("----------------------------------");
        System.out.println("Class.forName");
        // testForName(test1);
        System.out.println("----------------------------------");
        // System.out.println(Test2.class);
        // System.out.println(Test2.name);
        // System.out.println(Test1.class);
        System.out.println(Test1.name);
    }

    /**
     * classloader
     */

    private static void testClassloader(String test1) {
        Class<?> test1Class;
        ClassLoader loader = ClassLoader.getSystemClassLoader();
        try {
            test1Class = loader.loadClass(test1);
            System.out.println("test1   " + test1Class.getName());
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    private static void testForName(String test1) {
        try {
            Class<?> test1Class = Class.forName(test1);
            System.out.println("test1   " + test1Class.getName());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
